﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;

namespace Kaskelot.SP.Core
{
	public class XMLHelper
	{
		/// <summary>
		/// Writes eArkiv-specific element
		/// </summary>
		/// <param name="writer">Writer to write to</param>
		/// <param name="attributeName">Name of attribute</param>
		/// <param name="attributeValue">Value of attribute</param>
		public static void WriteAttribute(XmlWriter writer, string attributeName, string attributeValue)
		{
			XMLHelper.WriteTab(writer);
			//writer.WriteStartElement( "Attribute");
			writer.WriteRaw("<Attribute ");
			writer.WriteRaw("name=\"");
			writer.WriteRaw(attributeName + "\">");
			XMLHelper.WriteEndLine(writer);
			XMLHelper.WriteTab(writer);
			XMLHelper.WriteTab(writer);
			writer.WriteRaw("<Value>" + attributeValue + "</Value>");
			XMLHelper.WriteEndLine(writer);
			XMLHelper.WriteTab(writer);
			writer.WriteRaw("</Attribute>");
			XMLHelper.WriteEndLine(writer);
		}

		public static void WriteEndLine(XmlWriter writer)
		{
			writer.WriteRaw("\r\n");
		}

		public static void WriteTab(XmlWriter writer)
		{
			writer.WriteRaw("\t");
		}
	}
}
